//
//  SettingViewController.m
//  SuperRadio
//
//  Created by Damon on 14/12/17.
//  Copyright (c) 2014年 三个臭皮匠. All rights reserved.
//

#import "SettingViewController.h"
#import "SettingCell.h"
#import "ClearViewController.h"
#import "AboutUsViewController.h"

#import "HostLikeViewController.h"

@interface SettingViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain) UITableView *tableView;

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
  self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"设置";
    // Do any additional setup after loading the view.
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 155) style:UITableViewStylePlain];
    // 给tableView设置代理人
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    // 关掉弹动效果
    self.tableView.bounces = NO;
    // 设置滚动条 显示隐藏滚动条
    self.tableView.showsVerticalScrollIndicator = NO;
    
    [self.view addSubview:self.tableView];
    
    // 注册cell类
    [self.tableView registerClass:[SettingCell class] forCellReuseIdentifier:@"setting"];
    
    [_tableView release];
    
    // 导航栏 的按钮
//    self.navigationItem.rightBaranize target:self action:@selector(clicked:)];
    
    
}

// 导航栏右侧点击按钮
//- (void)clicked: (UIBarButtonItem *)barButton
//{
//    
//    HostLikeViewController *likeVC = [[HostLikeViewController alloc] init];
//    [self.navigationController pushViewController:likeVC animated:YES];
//    [likeVC release];
//}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

// 给cell赋值的方法
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SettingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"setting"];
    if (indexPath.row == 0) {
        
        NSString *path = [[NSBundle mainBundle] pathForResource:@"shanchu" ofType:@"png"];
        cell.setImageView.image = [UIImage imageWithContentsOfFile:path];
        
        cell.titleLabel.text = @"清除缓存";
        return cell;
        
        
    } else if (indexPath.row == 1) {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"png"];
        cell.setImageView.image = [UIImage imageWithContentsOfFile:path];
        
        cell.titleLabel.text = @"关于我们";
        return cell;
    }
    
    return 0;
    
    
}

// 选择cell后的方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) {
        // 当选择第0行 跳转清除缓存页面
        ClearViewController *clearVC = [[ClearViewController alloc] init];
        [self.navigationController pushViewController:clearVC animated:YES];
        [clearVC release];
    } else if (indexPath.row == 1) {
        // 当选择第1行 跳转关于我们的页面
        AboutUsViewController *aboutUsVC = [[AboutUsViewController alloc] init];
        [self.navigationController pushViewController:aboutUsVC animated:YES];
        [aboutUsVC release];
    }
    
}


- (void)dealloc
{
    [_tableView release];
    
    [super dealloc];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
